// -*- c++ -*-
/**************************************************************/
/*  This file is licensed from, and is a trade secret of:     */
/*                                                            */
/*    Mercury Computer Systems, Incorporated                  */
/*    199 Riverneck Road                                      */
/*    Chelmsford, Massachusetts 01824-2820                    */
/*    United States of America                                */
/*    Telephone + 1 978 256-1300                              */
/*                                                            */
/*  Refer to your Software License Agreement for provisions   */
/*  on use, duplication, or disclosure.                       */
/*  US. Government users and prime contractors are also       */
/*  governed by the following Data Rights Notice:             */
/*  Use, duplication or disclosure by the US. Government is   */
/*  subject to the provisions set forth in FAR 52.227-14 for  */
/*  restricted rights or other agency data rights provisions  */
/*  on commercial software and documentation, as applicable.  */
/*                                                            */
/*  This file: (a) was developed at private expense, and no   */
/*  part was developed with government funds, (b) is a        */
/*  trade secret of Mercury Computer Systems, Inc. for the    */
/*  purposes of the Freedom of Information Act, (c) is        */
/*  "commercial computer software" subject to limited         */
/*  utilization as provided in the above noted Software       */
/*  License Agreement and (d) is in all respects data         */
/*  belonging exclusively to Mercury Computer Systems, Inc..  */
/*                                                            */
/**************************************************************/

/******************************************************************/
/* Copyright (c) 1999-2003, Mercury Computer Systems, Inc.,       */
/* Chelmsford MA.,and all third party embedded software sources.  */
/* All rights reserved under the Copyright laws of US. and        */
/* international treaties.                                        */
/*                                                                */
/* Patent Pending                                                 */
/******************************************************************/


//$COPYRIGHT_END


#ifndef CF__PropertySet_impl_h
#define CF__PropertySet_impl_h

#include <map>
#include "cfS.h"
#include "cf__exp.h"

class __CF_EXPORT__ CF__PropertySet_impl
  : public virtual POA_CF::PropertySet
{
public:
  CF__PropertySet_impl (const CF::Properties & configProperties);
  CF__PropertySet_impl ();
  virtual ~CF__PropertySet_impl ();

  // From CF::PropertySet
  virtual void configure (const CF::Properties & configProperties)
    throw (CORBA::SystemException, CF::PropertySet::InvalidConfiguration,
           CF::PropertySet::PartialConfiguration);
  virtual void query (CF::Properties & configProperties)
    throw (CORBA::SystemException, CF::UnknownProperties);

  /*
   * Helper functions for component interface.  Only simple type
   * accessor functions are provided.  Complex property types still
   * need to use configure and query.
   */

    /*
     * This method returnd the index of the property associated with 
     * the specified property name.  If the property can't be found,
     * the method returns -1.  The property index can be used in
     * conjuction with the property accessor functions below.
     */

    int GetPropertyIndex (const char * property_name);

    /*
     * Property Accessor Functions.
     *
     * Accessor functions are supplied for the component to be able to
     * set and get properties for all of the simple property types.
     *
     * All return 0 if successful, -1 otherwise (either because the
     * property is not found or has the wrong property type.
     */

    int SetPropertyValue (int index, const CORBA::Boolean value);
    int SetPropertyValue (int index, const char *value);         // string
    int SetPropertyValue (int index, const CORBA::Char value);   // single char
    int SetPropertyValue (int index, const CORBA::Short value);
    int SetPropertyValue (int index, const CORBA::UShort value);
    int SetPropertyValue (int index, const CORBA::Long value);
    int SetPropertyValue (int index, const CORBA::ULong value);
    int SetPropertyValue (int index, const CORBA::Float value);
    int SetPropertyValue (int index, const CORBA::Double value);

    int GetPropertyValue (int index, CORBA::Boolean * value);
    int GetPropertyValue (int index, const char ** value);  // string
    int GetPropertyValue (int index, CORBA::Char * value);  // single char
    int GetPropertyValue (int index, CORBA::Short * value);
    int GetPropertyValue (int index, CORBA::UShort * value);
    int GetPropertyValue (int index, CORBA::Long * value);
    int GetPropertyValue (int index, CORBA::ULong * value);
    int GetPropertyValue (int index, CORBA::Float * value);
    int GetPropertyValue (int index, CORBA::Double * value);

private:
  CF__PropertySet_impl (const CF__PropertySet_impl & obj)
  {
  }

  void InitOrb (CORBA::ORB_ptr the_orb);

  // Originating here but may be overridden.
  virtual void InitProperties (const CF::Properties & configProperties);

  // Retrieve the index of a given property.
  int index (CF::DataType & prop);

  bool m_initialized;
  CF::Properties m_props;
  CORBA::ORB_var m_my_orb;
  std::map<std::string, int> m_property_index_mapping;
};

#endif
